package qin.com;
import java.util.List ;

public class ChengjiDao {
public static boolean insert(ChengJi chengJi){
    String sql = "insert into chengji(name,java,jsp,oracle) values(?,?,?,?)";
    Object[] objects = new Object[]{chengJi.getName(),chengJi.getJava(),chengJi.getJsp(),chengJi.getOracle()};
    return DataConnection.request(sql,  objects);
}
public static boolean update(ChengJi chengJi){
    String sql = "update chengji set name=?, java=?,jsp=?,oracle=? where id=?" ;
    Object[] objects = new Object[]{chengJi.getName(),chengJi.getJava(),chengJi.getJsp(),chengJi.getOracle(),chengJi.getId()};
    return DataConnection.request(sql , objects);
}

public static boolean delete(int id){
    String sql = "delete from chengji where id=?" ;
     Object[] objects = new Object[]{id} ;
     return DataConnection.request(sql , objects);
}

public static List<ChengJi> getAllChengJi(){
    String sql = "select id, name , java, jsp , oracle from chengji" ;
    List<ChengJi> list = new DataConnection<ChengJi>().query(ChengJi.class , sql , null) ;
    return list ;
}

    public static boolean checkChengJi(ChengJi chengJi){

        String sql="select id,name,java,jsp,oracle from users where name=? and java=? ane jsp=? ,oracle=?";

        Object[] para=new Object[]{chengJi.getName(),chengJi.getJava(),chengJi.getJsp(),chengJi.getOracle()};

        List<ChengJi> list=new DataConnection<ChengJi>().query(ChengJi.class,sql,para);

        if(list.size() >0){

            return true;

        }else{

            return false;

        }

    }

    public static ChengJi getChengJiById(int id){

        String sql="select id,name,java,jsp,oracle from users where id=?";

        Object[] para=new Object[]{id};

        List<ChengJi> list=new DataConnection<ChengJi>().query(ChengJi.class,sql,para);

        if(list.size() >0){

            return list.get(0);

        }else{

            return null;

        }

    }

}


